Example transformation of repetitive clinical trial analysis scripts:
Identify common functions across multiple studies
Standardize input/output formats
Create consistent documentation
Implement validation tests
Open Sourcing
Challenges in Pharmaceutical Programming
The pharmaceutical industry faces unique challenges in clinical and statistical programming:
Implementing patterns used across many table shells (developed by dedicated teams)
Company-specific statistical methods that need to be standardized
Complex table structures that must be consistent across studies
Need for a core framework that ensures all company shells can be created consistently
→ that where I step in !
Shells Are Table Specific, Table Creation Is Not
The Junco Package Approach
Our solution was to develop our own business logic framework for J&J table creation
Getting to Production
The Junco package provides key features needed for production-ready clinical tables:
True-type font support: Word wrapping, pagination, and RTF export
Higher order column counts: Utilities for spanning column headers
Guaranteed pathability in row space
Nearest-value (SAS-like) rounding support: Maintaining consistency with existing processes
Statistical calculations: In accord with business logic
Robust approach for risk diff columns
Creating the package
From Scripts to Standardized Tools
Industry Benefits
Creating R packages helps pharmaceutical companies:
Maintain consistency across studies and therapeutic areas
Reduce time spent on repetitive coding tasks
Improve compliance with regulatory standards
Facilitate knowledge transfer between team members
Code Design and API for Users
Once we had the core functionality working, we needed to focus on:
User-friendly API: Creating intuitive functions that match users’ mental models
Consistent interfaces: Ensuring functions work together seamlessly
Clear documentation: Making the package accessible to non-developers
Note
API design is one of the most critical and challenging aspects of writing good code
Documentation
Using roxygen2 and pkgdown
Documentation is critical for package adoption and proper use:
roxygen2 for function documentation:
#' Calculate risk difference with confidence intervals#'#' @param group1 Vector of outcomes for first group#' @param group2 Vector of outcomes for second group#' @param conf.level Confidence level (default: 0.95)#' @return A list with risk difference and Cis#' @exportrisk_diff <-function(group1, group2, conf.level =0.95) {# Function implementation}
pkgdown for website generation:
usethis::use_pkgdown()pkgdown::build_site()
Ensuring Package Quality
Unit Testing and Validation
Quality assurance is essential for pharmaceutical applications:
Unit tests: Verify each function works as expected -> Example
Integration tests: Ensure components work together correctly
Continuous Integration and Deployment
Automating Quality Checks
CI/CD reduces manual work while improving quality:
GitHub packages: Community collaboration, rapid development
CRAN packages: General-purpose tools, widely applicable methods → integrable with SPACE and package validation processes
Pharmaceutical Considerations
Internal packages often contain proprietary methods or company-specific workflows that shouldn’t be publicly shared, while more general statistical methods may benefit from community review through CRAN or GitHub distribution.
Open Sourcing in Pharma
Why Joining Efforts is More Efficient
Standardization: Common tools lead to more consistent and comparable analyses
Reduced duplication: Companies avoid solving the same problems repeatedly
Shared maintenance burden: Multiple companies contribute to maintaining core infrastructure
Broader testing: Diverse use cases identify edge cases and bugs more effectively
Industry Transformation
The pharmaceutical industry is increasingly recognizing that pre-competitive collaboration on analytical tools benefits everyone. Projects like the R Validation Hub and Pharmaverse demonstrate how shared open source efforts can accelerate innovation while reducing costs.